|
|
|
|
|
|
|
Q When must you raise an error? |
|
|
|
|
|
|
|
|
A When you design your component to allow a client application to handle an error, you must raise that error. That is, the method in your component that trapped the error tells the compiler to notify the previous method (of the client application) on the call stack that it must catch the error your component is raising up the stack. It's sort of like playing hot potatoes, only you're passing the hot potato up the call stack to the body of code that called your component. Raising an error involves the Raise method. |
|
|
|
|
|
|
|
|
The workshop includes quiz questions to help gauge your grasp of the material. You'll find the answers to this quiz in Appendix A, Answers. Even if you feel that you totally understand the concepts presented here, you should work through the quiz anyway. The last section contains exercises for you to work through to help reinforce your learning. |
|
|
|
|
|
|
|
|
1. True or False: Every significant class method and code module function (if any) requires initial error handling. |
|
|
|
|
|
|
|
|
2. What three steps are typically involved in implementing inline error handling in your methods? |
|
|
|
|
|
|
|
|
3. What statement initiates your error traps? |
|
|
|
|
|
|
|
|
4. Is it okay to do very complex error handling in every method? |
|
|
|
|
|
|
|
|
5. What are the various kinds of methods for which you must plan? |
|
|
|
|
|
|
|
|
1. Copy the code for the Samsona Bank Teller System from the CD-ROM to somewhere on your hard disk. Add error-handling code, similar to Listing 18.6, to the withdraw method of the WithdrawFunds class. |
|
|
|
|
|
|
|
|
2. Based on exercise 1, add error-handling code to the public methods of the following classes: Process, Role, User, SecurityPolicy, TransactionProcessor, OpenAccount, CloseAccount. Byte |
|
|
|
|
|